import { HttpClient } from "@angular/common/http";
import { Component, Inject, OnInit } from "@angular/core";
import { Observable } from "rxjs";

import { DataRenderChanged, DataRenderToken } from "@/app/components/DataRender/datarender.component";
import { DataRenderColumn, iWorkflowPagedData, iWorkflowResponse } from "@/app/types/Core";
import { ToDoSO } from "@/app/pages/iworkflow/types/ToDoSO";

@Component({
  selector: 'iworkflow-todo',
  templateUrl: './index.html'
})
export class ToDoComponent implements OnInit {
  datas = new iWorkflowPagedData();

  columns = [
    { title: '项目名', dataIndex: 'projectName', width: 130 },
    { title: '流程名', dataIndex: 'processName', width: 200 },
    { title: '流水号', dataIndex: 'serialNumber', width: 200, slot: 'serialNumber' },
    { title: '状态', dataIndex: 'workflowStatus', width: 100, slot: 'status' }
  ] as DataRenderColumn[];

  so = {
    CurrentPage: 1,
    PageSize: 10,
    Keywords: "",
    UserId: "dc\\LuJuan1",
    WorkflowStatus: ["3", "4"],
    ProcessStartDateBegin: "2022-01-14",
    ProcessStartDateEnd: "2022-04-14",
    LastApproveDateBegin: "",
    LastApproveDateEnd: "",
    AmountSmall: "",
    AmountLarge: "",
    RelativeUnit: "",
    APELastApproveDateBegin: "",
    APELastApproveDateEnd: "",
    APEComment: "",
    IsNullApprover: "true",
    InvoiceNumberType: false,
    ProjectIds: [],
    ProcessGroupIds: []
  } as ToDoSO;

  constructor (@Inject(DataRenderToken) dataRenderChanged: Observable<DataRenderChanged>) {
    dataRenderChanged.subscribe(u => {
      console.log(u.type);
    });
  }

  ngOnInit(): void {

  }

  search(dbRender: any) {
    dbRender.reSearch();
  }

  getRouteUrl(item: any) {
    return `/iworkflow/${item.processID}/${item.bizFormID}/detail`;
  }
}